<?php

namespace App\Http\Controllers\admin;

use App\Dao\UsersDao;
use App\Services\Code;

class UsersController extends BaseController
{
    public function users()
    {
        if(getIsHasPage()){
            $params = request()->all();
            return  Code::message('',200,UsersDao::pageinate($params));
        }
        return view('admin.users.users');
    }

    public function recharge(): array
    {
        $params = request()->all();
        UsersDao::recharge($params);
        return Code::message('',200);
    }


    public function recharge_score(): array
    {
        $params = request()->all();
        UsersDao::recharge_score($params);
        return Code::message('',200);
    }


    public function edit()
    {
        if(isPost()){
            $params = request()->all();
            UsersDao::edit($params);
            return Code::message('',200);
        }
        $info = UsersDao::builder_user_query([
            'user_id'=>request('user_id')
        ])->first();
        return  view('admin.users.edit',[
            'info'=>$info
        ]);
    }
}
